/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-05-23
 * Time: 20:27
 */
/*
    给定一个字符串 s ，请你找出其中不含有重复字符的 最长子串 的长度。
 */
public class test2 {
    public static void main(String[] args) {
        int ret = findMaxLength("ababc");
        System.out.println(ret);
    }

    public static int findMaxLength(String str){
        char[] c = str.toCharArray();
        int left = 0;
        int right= 0;
        int n = str.length();
        int ret = 0;
        int[] hash = new int[128];
        while(right<n){
            hash[c[right]]++;
            if(hash[c[right]]>1){
                hash[c[left]]--;
                left++;
            }
            ret = Math.max(ret,right-left+1);
            right++;
        }
        return ret;
    }
}
